package com.xyht.sca_s.student_manage_system.modules.produtProcurement.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.produtProcurement.entity.SmsProductProcurementApprovalProcess;
import com.xyht.sca_s.student_manage_system.modules.produtProcurement.mapper.SmsProductProcurementApprovalProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ProductProcurementInit {

    @Autowired
    private SmsProductProcurementApprovalProcessMapper smsProductProcurementApprovalProcessMapper;

    private String[] departmentNameArray = {"后勤部门","分管院长","院长", "董事长"};

    @Bean
    public void productProcurementApprovalInit() {
        List<SmsProductProcurementApprovalProcess> processList =
                smsProductProcurementApprovalProcessMapper.selectList(new QueryWrapper<>());
        if (processList == null || processList.size() < 1) {
            int sort = 1;
            for (String departmentName : departmentNameArray) {
                SmsProductProcurementApprovalProcess addProcess =
                        new SmsProductProcurementApprovalProcess();
                addProcess.setProcessName(departmentName);
                addProcess.setProcessIsUse(true);
                addProcess.setProcessIsStamp(false);
                addProcess.setProcessIsSign(true);
                addProcess.setProcessIsApplicantEdit(false);
                addProcess.setProcessSort(sort++);
                smsProductProcurementApprovalProcessMapper.insert(addProcess);
            }


        }
    }

}
